home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / pgp20src.zip / ZIP.H < prev    next >
C/C++ Source or Header  |  1992-08-19  |  4KB  |  155 lines

  1. /*
  2.  
  3.  Copyright (C) 1990,1991 Mark Adler, Richard B. Wales, and Jean-loup Gailly.
  4.  Permission is granted to any individual or institution to use, copy, or
  5.  redistribute this software so long as all of the original files are included
  6.  unmodified, that it is not sold for profit, and that this copyright notice
  7.  is retained.
  8.  
  9. */
  10.  
  11. /*
  12.  *  zip.h by Mark Adler.
  13.  */
  14.  
  15.  
  16. /* Set up portability */
  17. #include "ztailor.h"
  18.  
  19. #define MIN_MATCH  3
  20. #define MAX_MATCH  258
  21. /* The minimum and maximum match lengths */
  22.  
  23. #ifndef WSIZE
  24. #  define WSIZE  8192    /* for PGP only use 8192 */
  25. #endif
  26. /* Maximum window size = 32K. If you are really short of memory, compile
  27.  * with a smaller WSIZE but this reduces the compression ratio for files
  28.  * of size > WSIZE.
  29.  */
  30.  
  31. #define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
  32. /* Minimum amount of lookahead, except at the end of the input file.
  33.  * See deflate.c for comments about the MIN_MATCH+1.
  34.  */
  35.  
  36. #define MAX_DIST  (WSIZE-MIN_LOOKAHEAD)
  37. /* In order to simplify the code, particularly on 16 bit machines, match
  38.  * distances are limited to MAX_DIST instead of WSIZE.
  39.  */
  40.  
  41. /* Define malloc() and string functions */
  42. #ifdef MODERN
  43. #  include <string.h>
  44. #else /* !MODERN */
  45.    voidp *malloc();
  46.    voidp *calloc();
  47.    char *getenv();
  48.    long atol();
  49.    char *strcpy();
  50.    char *strcat();
  51.    char *strchr();
  52.    char *strrchr();
  53. #  ifndef ZMEM
  54.      char *memset();
  55.      char *memcpy();
  56. #  endif /* !ZMEM */
  57. #endif /* ?MODERN */
  58.  
  59. /* Define fseek() commands */
  60. #ifndef SEEK_SET
  61. #  define SEEK_SET 0
  62. #endif /* !SEEK_SET */
  63.  
  64. #ifndef SEEK_CUR
  65. #  define SEEK_CUR 1
  66. #endif /* !SEEK_CUR */
  67.  
  68. #ifndef SEEK_END
  69. #  define SEEK_END 2
  70. #endif /* !SEEK_END */
  71.  
  72. /* For setting stdout to binary */
  73. #ifdef MSDOS
  74. #  include <io.h>
  75. #  include <fcntl.h>
  76. #endif /* MSDOS */
  77.  
  78. /* Types centralized here for easy modification */
  79. #define local static            /* More meaningful outside functions */
  80. typedef unsigned char uch;      /* unsigned 8-bit value */
  81. typedef unsigned short ush;     /* unsigned 16-bit value */
  82. typedef unsigned long ulg;      /* unsigned 32-bit value */
  83.  
  84.  
  85. /* Error return codes and PERR macro */
  86. #include "ziperr.h"
  87.  
  88. /* Internal attributes */
  89. #define UNKNOWN        -1
  90. #define BINARY        0
  91. #define ASCII        1
  92.  
  93. /* Public globals */
  94. #define BEST -1                 /* Use best method (deflation or store) */
  95. #define STORE 0                 /* Store method */
  96. #define DEFLATE 8               /* Deflation method*/
  97. extern int method;              /* Restriction on compression method */
  98. extern int level;               /* Compression level */
  99.  
  100. /* Diagnostic functions */
  101. #ifdef DEBUG
  102. # ifdef MSDOS
  103. #  undef  stderr
  104. #  define stderr stdout
  105. # endif
  106. #  define diag(where) fprintf(stderr, "zip diagnostic: %s\n", where)
  107. #  define Assert(cond,msg) {if(!(cond)) error(msg);}
  108. #  define Trace(x) fprintf x
  109. #  define Tracev(x) {if (verbose) fprintf x ;}
  110. #  define Tracevv(x) {if (verbose>1) fprintf x ;}
  111. #  define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
  112. #  define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
  113. #else
  114. #  define diag(where)
  115. #  define Assert(cond,msg)
  116. #  define Trace(x)
  117. #  define Tracev(x)
  118. #  define Tracevv(x)
  119. #  define Tracec(c,x)
  120. #  define Tracecv(c,x)
  121. #endif
  122.  
  123.  
  124. /* Public function prototypes */
  125.  
  126.         /* in zip.c, zipcloak.c, or zipsplit.c */
  127. void err   OF((int c, char *h));
  128. void error OF((char *h));
  129.  
  130.         /* in zipup.c */
  131. int zipup OF((FILE *inFile, FILE *outFile));
  132. int read_buf OF((char far *buf, unsigned size));
  133.  
  134. #  define zfwrite fwrite /* ??? far */
  135. #  define zputc putc
  136.  
  137.         /* in deflate.c */
  138. void lm_init OF((int pack_level, ush *flags));
  139. ulg  deflate OF((void));
  140.  
  141.         /* in trees.c */
  142. void ct_init     OF((ush *attr, int *method));
  143. int  ct_tally    OF((int dist, int lc));
  144. ulg  flush_block OF((char *buf, ulg stored_len, int eof));
  145.  
  146.         /* in bits.c */
  147. void     bi_init    OF((FILE *zipfile));
  148. void     send_bits  OF((int value, int length));
  149. unsigned bi_reverse OF((unsigned value, int length));
  150. void     bi_windup  OF((void));
  151. void     copy_block OF((char far *buf, unsigned len, int header));
  152.  
  153.  
  154. /* end of zip.h */
  155.